package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.dao.DishFlavorDao;
import com.itheima.entity.DishFlavor;
import com.itheima.service.DishFlavorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DishFlavorServiceImpl implements DishFlavorService {

    @Autowired
    DishFlavorDao dishFlavorDao;

    @Override
    public Integer addDishFlavor(DishFlavor dishFlavor) {


        return dishFlavorDao.insert(dishFlavor);
    }

    @Override
    public List<DishFlavor> getByIdFlavor(Long dishId) {
        LambdaQueryWrapper<DishFlavor> lqw = new LambdaQueryWrapper<>();
        lqw.eq(DishFlavor::getDishId, dishId);

        return dishFlavorDao.selectList(lqw);
    }

    @Override
    public Integer deleteByDishIdDishFlavor(Long dishId) {

        LambdaQueryWrapper<DishFlavor> lqw = new LambdaQueryWrapper<>();
        lqw.eq(DishFlavor::getDishId,dishId);


        return   dishFlavorDao.delete(lqw);
    }


}
